package org.lucene.util;

import java.io.IOException;
import java.io.Reader;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;

import com.chenlb.mmseg4j.Dictionary;
import com.chenlb.mmseg4j.MaxWordSeg;
import com.chenlb.mmseg4j.analysis.MMSegTokenizer;

public class MySameAnalyzer extends Analyzer {
    private SamewordContext samewordContext;

    public MySameAnalyzer(SamewordContext swc) {
        samewordContext = swc;
    }

    @Override
    public final TokenStream tokenStream(String fieldName, Reader reader) {
        Dictionary dic = Dictionary.getInstance("E:\\opensource\\mmseg4j-master\\mmseg4j-master\\data");
        return new MySameTokenFilter(new MMSegTokenizer(new MaxWordSeg(dic), reader), samewordContext);
    }

    @Override
    public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
        return super.reusableTokenStream(fieldName, reader);
    }

}
